package com.starview.star.compiler.format.rules;

import com.starview.platform.data.type.Location;
import com.starview.star.compiler.ast.Apply;
import com.starview.star.compiler.ast.IAbstract;
import com.starview.star.compiler.util.PrettyPrintDisplay;

@SuppressWarnings("serial")
public class FmtApplyApplyBuild implements FmtBuildOp
{
  private final FmtBuildOp op, arg;

  public FmtApplyApplyBuild(FmtBuildOp op, FmtBuildOp arg)
  {
    this.op = op;
    this.arg = arg;
  }

  @Override
  public IAbstract build(IAbstract[] env, Location loc)
  {
    IAbstract op = this.op.build(env, loc);
    Apply args = (Apply) this.arg.build(env, loc);
    return new Apply(loc, op, args.getArgs());
  }

  @Override
  public void prettyPrint(PrettyPrintDisplay disp)
  {
    op.prettyPrint(disp);
    disp.append("@");
    arg.prettyPrint(disp);
  }
}
